import React, { Component } from "react";
import { Table, Tabs, Button } from "antd";
import Articles from "../Article/Articles";
import ArticlesMon from "../Article/ArticlesMon";
import DataStatistics from "../DataStatistics/DataStatistics";
import { judgeMonCode } from '@/utils/formatMonTextStyle.js'

const { TabPane } = Tabs;

class PushedTab extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  goBack = () => {
    this.props.parentBack();
  };
  export = () => {
    window.location.href = `http://nmsaas.nmgcyy.com.cn/supervise/v1/content/exportPushData?id=${this.props.id}`
  }
  render() {
    const columns = [
      {
        title: "站点序号",
        dataIndex: "index",
        key: "index",
        align: "center",
        render: (text, record, index) => {
          return index + 1;
        }
      },
      {
        title: "站点名称",
        dataIndex: "site_name",
        key: "site_name",
        align: "center"
      },
      {
        title: "推送人",
        dataIndex: "execute_user",
        key: "execute_user",
        align: "center"
      },
      {
        title: "分发反馈",
        dataIndex: "distribute_status",
        key: "distribute_status",
        align: "center",
        render: (status) => {
          if (status === 0) {
            return <span style={{ color: "rgb(39, 139, 255)" }}>待处理</span>;
          }
          if (status === 1) {
            return <span style={{ color: "rgb(49, 173, 55)" }}>已分发</span>;
          }
          if (status === 2) {
            return <span style={{ color: "#EE4D61" }}>拒绝分发</span>;
          }
        },
      },
      {
        title: "文章详情",
        dataIndex: "h5_url",
        key: "h5_url",
        align: "center",
        render: (url) => {
          return <a href={url} rel="noreferrer" target="_blank">详情链接</a>
        },
      },
      {
        title: "发布时间",
        dataIndex: "push_time",
        key: "push_time",
        align: "center"
      }
      // {
      //   title: "操作",
      //   key: "action",
      //   // dataIndex: "action",
      //   align: "center",
      //   render: (text, record) => {
      //     return <span style={{ color: "#1890ff" }}>查看</span>;
      //   }
      // }
    ];
    console.log(this.props.TableData)
    return (
      <Tabs
        defaultActiveKey={this.props.tabKey}
        onChange={() => { }}
        tabBarExtraContent={
          <div>
            <Button onClick={this.goBack}>返回上一级</Button>
          </div>
        }
      >
        <TabPane tab="推送数据" key="1" disabled={!this.props.statistivarable}>
          <Button type="primary" onClick={this.export} style={{ marginBottom: '10px' }}>数据导出</Button>
          <Table loading={this.props.Loading} columns={columns} rowKey={recored => recored.site_id} dataSource={this.props.TableData} bordered pagination={10} />
        </TabPane>
        <TabPane tab="文章内容" key="2">
          {/* 判断中文 或者 蒙文 稿件 */}
          {/* {judgeMonCode(this.props.contentData.title) ?
            <ArticlesMon handleGoBack={this.goBack} detailsContent={this.props} />
          :
            <Articles handleGoBack={this.goBack} detailsContent={this.props} />
          } */}

          <ArticlesMon handleGoBack={this.goBack} detailsContent={this.props} />
        </TabPane>
        <TabPane tab="数据统计" key="3">
          <DataStatistics statisticalData={this.props.statisticalData} />
        </TabPane>
      </Tabs>
    );
  }
}

export default PushedTab;
